package com.rr.esdemo.entity;

import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * @author RR
 * @date 2023/2/15 14:20
 */
@Getter
@Setter
// 索引名：product，主分片3，副本1
@Document(indexName = "product",shards = 3,replicas = 1)
public class Product {
    @Id
    private Long id;
    @Field(type = FieldType.Text)
    private String title;
    @Field(type = FieldType.Keyword)
    private String category;
    @Field(type = FieldType.Double)
    private Double price;
    @Field(type = FieldType.Keyword, index = false)
    private String images;
    @Field(type = FieldType.Keyword)
    private List<Integer> tagIds;
    @Field(type = FieldType.Nested)
    private List<SalesInfo> salesInfos;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class SalesInfo {
        private LocalDate date;
        private Integer count;
    }
}
